import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
import 'package:sports_new/widgets/base/qkd_text.dart';

import '../../resources/colours.dart';
import '../../utils/utils.dart';

class LoadingIndicator extends StatelessWidget {
  const LoadingIndicator({super.key, this.isSilver = false});
  const LoadingIndicator.sliver({super.key}) : isSilver = true;

  final bool isSilver;

  @override
  Widget build(BuildContext context) {
    if(isSilver) {
      return SliverLayoutBuilder(
        builder: (context, constraints) => SliverToBoxAdapter(
        child: SizedBox(
          height: constraints.viewportMainAxisExtent,
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Lottie.asset(
                    Utils.getFilePath("refresh_indicator.json"),
                    repeat: true,
                    fit: BoxFit.fitHeight,
                    height: 80,
                    width: 80
                ),
                const QkdText("努力加载中", color: Colours.grey66)
              ],
            ),
          ),
        )
            ),
      );
    } else {
      return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Lottie.asset(
              Utils.getFilePath("refresh_indicator.json"),
              repeat: true,
              fit: BoxFit.fitHeight,
              height: 80,
              width: 80
          ),
          const QkdText("努力加载中", color: Colours.grey66)
        ],
      ),
    );
    }
  }
}
